<template>
  <view class="deposit">
<!--    <view-->
<!--      class="padding-top-sm padding-bottom-sm w-bj-white margin-top-xs checkBoxItem"-->
<!--    >-->
<!--      <view class="padding-left-sm">-->
<!--        <view class="text-sml">-->
<!--          <span class="text-bold-lg">存款方式</span>-->
<!--        </view>-->
<!--      </view>-->

<!--      <view class="margin-top-xs">-->
<!--        <view class="van-grid" style="padding-left: 0.8rem">-->
<!--          <view-->
<!--            class="van-grid-item"-->
<!--            style="flex-basis: 33.3333%; padding-right: 0.8rem"-->
<!--            @click="activeIndex = index"-->
<!--            v-for="(item, index) in list"-->
<!--            :key="index"-->
<!--            :class="{ active: activeIndex === index }"-->
<!--          >-->
<!--            <view-->
<!--              class="van-grid-item__content van-grid-item__content&#45;&#45;horizontal van-grid-item__content&#45;&#45;center van-grid-item__content&#45;&#45;surround van-hairline"-->
<!--            >-->
<!--              <image class="icon" :src="item.icon" mode="widthFix"></image>-->
<!--              <span class="van-grid-item__text">{{ item.title }}</span>-->
<!--            </view>-->
<!--          </view>-->
<!--        </view>-->
<!--      </view>-->
<!--    </view>-->

    <view
      class="padding-top-sm padding-bottom-sm w-bj-white margin-top-xs checkBoxItem"
    >
      <view class="padding-left-sm">
        <view class="text-sml">
          <span class="text-bold-lg">存款金额</span>
        </view>
      </view>
      <view class="van-cell van-field">
        <view class="van-cell__value van-field__value">
          <view class="van-field__body">
            <input
              id="van-field-10-input"
              type="text"
              v-model="amoney"
              class="van-field__control"
              placeholder="请输入存款金额"
            />
          </view>
        </view>
      </view>
      <!-- <view class="margin-top-sm" v-if="activeIndex != 0 && activeIndex != 3">
				<view class="van-grid" style="padding-left: 0.8rem;">
					<view class="van-grid-item" style="flex-basis: 33.3333%; padding-right: 0.8rem;" v-for="(item,index) in priceList" :key="index" @click="price = item">
						<view class="van-grid-item__content van-grid-item__content--horizontal van-grid-item__content--center van-grid-item__content--surround van-hairline">
							<span class="text-bold">{{item}}</span>
						</view>
					</view>
				</view>
			</view> -->
    </view>

    <view class="padding-sm">
      <button
        @click="deposit()"
        :disabled="!amoney || loading"
        class="van-button van-button--primary van-button--normal van-button--block"
        :class="{ 'van-button--disabled': (!amoney || loading) }"
      >
        <view class="van-button__content">
          <span class="van-button__text">确定</span>
        </view>
      </button>

<!--      <view class="padding-top-sm text-center">-->
<!--        遇到问题？联系-->
<!--        <span class="text-color-blue" @click="toIm()">在线客服</span> 解决-->
<!--      </view>-->
    </view>
  </view>
</template>

<script>
import icon1 from "../../../static/index/yhk.png";
import icon2 from "../../../static/index/wx.png";
import icon3 from "../../../static/index/zfb.png";
import icon4 from "../../../static/index/JD.png";
import $H from '@/pages/common/request.js'
export default {
  data() {
    return {
      list: [
        {
          title: "银行卡转账",
          icon: icon1,
        },
        {
          title: "微信支付",
          icon: icon2,
        },
        {
          title: "支付宝支付",
          icon: icon3,
        },
        // {
        // 	title: 'JDPay',
        // 	icon: icon4
        // },
      ],
      activeIndex: 0,
      amoney: null,
      loading:false,
      priceList: [100, 200, 50],
    };
  },
  methods: {
    deposit() {
      // uni.showToast({
      //   title: "请联系在线客服",
      //   duration: 1000,
      //   icon: "none",
      // });
      this.submitForm();
    },

    submitForm() {
      if(this.loading){
        return
      }
      this.loading = true;
      if (Number(this.amoney < 1)) {
        return uni.showToast({
          title: '存款金额不能为空',
          duration: 1000,
          icon: 'none'
        });
      }

      let then = this

        $H.post('/app_user_wallet', {
          type: 'save',
          amoney: then.amoney
        }).then((res) => {
          console.log(res)
          if (res.code == 200) {
            // setTimeout(()=>{
            //   this.routerBack()
            // }, 2000)
            return uni.showToast({
              title: res.msg,
              duration: 2000,
              icon: 'none'
            });
            then.loading=false
          }
        })


    },

    toIm() {
      uni.switchTab({
        url: "/pages/im/imdetails",
      });
    },
  },
};
</script>

<style scoped lang="scss">
.van-grid {
  .van-grid-item {
    margin-bottom: 0.8rem;
    .van-grid-item__content {
      display: flex;
      padding: 2.13333vw 0;
      align-items: center;
      justify-content: center;
      box-sizing: border-box;
      height: 100%;
      background-color: #fff;
      border-radius: 20rpx;
      .icon {
        width: 44rpx;
        margin-right: 10rpx;
      }
    }
  }

  .active {
    .van-grid-item__content {
      border: 1px solid #f4af00;
    }
  }
}

.van-cell {
  line-height: 8vw;
  position: relative;
  display: flex;
  box-sizing: border-box;
  width: 100%;
  padding: 2.66667vw 4.26667vw;
  overflow: hidden;
  color: #323233;
  font-size: 3.73333vw;
  background: #fff;

  .van-field__value {
    overflow: visible;
  }

  .van-cell__value {
    position: relative;
    overflow: hidden;
    color: #969799;
    text-align: right;
    vertical-align: middle;
    word-wrap: break-word;
    .van-field__body {
      display: flex;
      align-items: center;
      .van-field__control {
        display: block;
        box-sizing: border-box;
        width: 100%;
        min-width: 0;
        margin: 0;
        padding: 0;
        color: #323233;
        line-height: inherit;
        text-align: left;
        background-color: transparent;
        border: 0;
        resize: none;
        -webkit-user-select: auto;
        user-select: auto;
      }
    }
  }
}

.van-field {
  flex-wrap: wrap;
}
</style>